home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / oogl.5 < prev   
Encoding:
Text File  |  1993-11-16  |  37.1 KB  |  1,100 lines

  1. ./"
  2. ./" DO NOT EDIT THIS FILE DIRECTLY!  It is generated automatically
  3. ./"  from the Geomview manual.  Make changes in the manual, not here.
  4. ./"
  5. .TH OOGL 5 "Mon Nov 15 21:35:41 CST 1993" "Geometry Center"
  6. .SH NAME
  7. OOGL \- File formats for OOGL geometric objects
  8. .SH NOTE
  9. The material in this manual page also appears in the Geomview manual.
  10. .SH DESCRIPTION
  11. .nf
  12. .na
  13.  
  14. OOGL File Formats
  15. *****************
  16.  
  17. The objects that you can load into Geomview are called OOGL objects.
  18. OOGL stands for "Object Oriented Graphics Library"; it is the library
  19. upon which Geomview is built.
  20.  
  21. There are many different kinds of OOGL objects.  This chapter gives
  22. syntactic descriptions of file formats for OOGL objects.
  23.  
  24. Examples of most file types live in Geomview's `data/geom'
  25. directory.
  26.  
  27. Conventions
  28. ===========
  29.  
  30. Syntax Common to All OOGL File Formats
  31. --------------------------------------
  32.  
  33. Most OOGL object file formats are free-format ASCII --- any amount of
  34. white space (blanks, tabs, newlines) may appear between tokens (numbers,
  35. key words, etc.).  Line breaks are almost always insignificant, with a
  36. couple of exceptions as noted.  Comments begin with # and continue to
  37. the end of the line; they're allowed anywhere a newline is.
  38.  
  39. Binary formats are also defined for several objects; *Note Binary format::, and the individual object descriptions.
  40.  
  41. Typical OOGL objects begin with a key word designating object type,
  42. possibly with modifiers indicating presence of color information etc.
  43. In some formats the key word is optional, for compatibility with file
  44. formats defined elsewhere.  Object type is then determined by
  45. guessing from the file suffix (if any) or from the data itself.
  46.  
  47. Key words are case sensitive.  Some have optional prefix letters
  48. indicating presence of color or other data; in this case the order of
  49. prefixes is significant, e.g. `CNMESH' is meaningful but
  50. `NCMESH' is invalid.
  51.  
  52.  
  53. File Names
  54. ----------
  55.  
  56. When OOGL objects are read from disk files, the OOGL library uses the
  57. file suffix to guess at the file type.
  58.  
  59. If the suffix is unrecognized, or if no suffix is available (e.g. for an
  60. object being read from a pipe, or embedded in another OOGL object), all
  61. known types of objects are tried in turn until one accepts the data as
  62. valid.
  63.  
  64.  
  65. Vertices
  66. --------
  67.  
  68. Several objects share a common style of representing vertices with
  69. optional per-vertex surface-normal and color.  All vertices within an
  70. object have the same format, specified by the header key word.
  71.  
  72. All data for a vertex is grouped together (as opposed to e.g. giving
  73. coordinates for all vertices, then colors for all vertices, and so on).
  74.  
  75. The syntax is
  76.  
  77. `X  Y  Z'
  78.      (3-D floating-point vertex coordinates) or
  79. `X  Y  Z  W'
  80.      (4-D floating-point vertex coordinates)
  81.  
  82. optionally followed by
  83.  
  84. `NX  NY  NZ'
  85.      (normalized 3-D surface-normal if present)
  86.  
  87. optionally followed by
  88.  
  89. `R  G  B  A'
  90.      (4-component floating-point color if present, each component in range
  91.      0..1.  The A (alpha) component represents opacity: 0 transparent, 1
  92.      opaque.)
  93.  
  94. Values are separated by white space, and line breaks
  95. are immaterial.
  96.  
  97.  
  98. Surface normal directions
  99. -------------------------
  100.  
  101. Geomview uses normal vectors to determine how an object is shaded.
  102. The direction of the normal is significant in this calculation.
  103.  
  104. When normals are supplied with an object, the direction of the normal
  105. is determined by the data given.
  106.  
  107. When normals are not supplied with the object, Geomview computes normal
  108. vectors automatically; in this case normals point toward the side from
  109. which the vertices appear in counterclockwise order.
  110.  
  111. On parametric surfaces (Bezier patches), the normal at point P(u,v)
  112. is in the direction dP/du cross dP/dv.
  113.  
  114.  
  115. Transformation matrices
  116. -----------------------
  117.  
  118. Some objects incorporate 4x4 real matrices for homogeneous object
  119. transformations.  These matrices act by multiplication on the right of
  120. vectors.  Thus, if p is a 4-element row vector representing homogeneous
  121. coordinates of a point in the OOGL object, and A is the 4x4 matrix, then
  122. the transformed point is p' = p A.  This matrix convention is common in
  123. computer graphics; it's the transpose of that often used in mathematics,
  124. where points are column vectors multiplied on the right of matrices.
  125.  
  126.  
  127. Thus for Euclidean transformations, the translation components appear in
  128. the fourth row (last four elements) of A.  A's last column (4th, 8th,
  129. 12th and 16th elements) are typically 0, 0, 0, and 1 respectively.
  130.  
  131.  
  132. Binary format
  133. -------------
  134.  
  135. Many OOGL objects accept binary as well as ASCII file formats.
  136. These files begin with the usual ASCII token (e.g. `CQUAD')
  137. followed by the word `BINARY'.
  138. Binary data begins at the byte following the first newline after
  139. `BINARY'.  White space and a single comment may intervene, e.g.
  140.  
  141.      OFF BINARY    # binary-format "OFF" data follows 
  142.  
  143. Binary data comprise 32-bit integers and 32-bit IEEE-format floats, both
  144. in big-endian format (i.e., with most significant byte first).  This is
  145. the native format for 'int's and 'float's on Sun-3's, Sun-4's, and
  146. Irises, among others.
  147.  
  148. Binary data formats resemble the corresponding ASCII formats, with ints
  149. and floats in just the places you'd expect.  There are some exceptions
  150. though, specifically in the `QUAD' and `OFF' file formats.
  151. Details are given in the individual file format descriptions.
  152. *Note QUAD::, and *Note OFF::.
  153.  
  154. Binary OOGL objects may be freely mixed in ASCII object streams:
  155.  
  156.      LIST
  157.      { = MESH BINARY
  158.      ... binary data for mesh here ...
  159.      }
  160.      { = QUAD
  161.          1 0 0   0 0 1   0 1 0  0 1 0
  162.      }
  163.  
  164. Note that ASCII data resumes immediately following the last byte of
  165. binary data.
  166.  
  167. Naturally, it's impossible to embed comments inside a binary-format OOGL
  168. object, though comments may appear in the header before the beginning of
  169. binary data.
  170.  
  171.  
  172. Embedded objects and external-object references
  173. -----------------------------------------------
  174.  
  175. Some object types (`LIST', `INST') allow references to other
  176. OOGL objects, which may appear literally in the data stream, be loaded
  177. from named disk files, or be communicated from elsewhere via named
  178. objects.  Gcl commands also accept geometry in these forms.
  179.  
  180. The general syntax is
  181.  
  182.       <oogl-object>  ::=
  183.          [ "{" ]
  184.              [ "define" `symbolname' ]
  185.              [ "appearance" `appearance' ]
  186.              [ ["="] `object-keyword' ...
  187.               | "<" `filename'
  188.               | ":" `symbolname' ]
  189.          [ "}" ]
  190.  
  191. where "quoted" items are literal strings (which appear without the
  192. quotes), [bracketed] items are optional, and | denotes alternatives.
  193. Curly braces, when present, must match; the outermost set of curly
  194. braces is generally required when the object is in a larger context,
  195. e.g. when it is part of a larger object or embedded in a Geomview
  196. command stream.
  197.  
  198. For example, each of the following three lines:
  199.          { define fred   QUAD 1 0 0  0 0 1  0 1 0  1 0 0 }
  200.  
  201.          { appearance { +edge } LIST { < "file1" } { : fred } }
  202.  
  203.          VECT 1 2 0   2 0   0 0 0   1 1 2
  204. is a valid OOGL object.  The last example is only valid when it is
  205. delimited unambiguously by residing in its own disk file.
  206.  
  207. The "<" construct causes a disk file to be read.  Note that this isn't a
  208. general textual "include" mechanism; a complete OOGL object must appear
  209. in the referenced file.
  210.  
  211. Files read using "<" are sought first in the directory of the file which
  212. referred to them, if any; failing that, the normal search path (set by
  213. Geomview's `load-path' command) is used.  The default search looks
  214. first in the current directory, then in the Geomview data directories.
  215.  
  216. The ":" construct allows references to symbols, created with
  217. `define'.  A symbol's initial value is a null object.  When a
  218. symbol is (re)defined, all references to it are automatically changed;
  219. this is a crucial part of the support for interprocess communication.
  220. Some future version of the documentation should explain this better...
  221.  
  222. Again, white space and line breaks are insignificant, and "#" comments
  223. may appear anywhere.
  224.  
  225.  
  226.  
  227. Appearances
  228. -----------
  229.  
  230. Geometric objects can have associated "appearance" information,
  231. specifying shading, lighting, color, wireframe vs. shaded-surface
  232. display, and so on.  Appearances are inherited through object
  233. hierarchies, e.g. attaching an appearance to a `LIST' means that the
  234. appearance is applied to all the `LIST''s members.
  235.  
  236. Some appearance-related properties are relegated to "material" and
  237. "lighting" substructures.  Take care to note which properties belong to
  238. which structure.
  239.  
  240. Here's an example appearance structure including values for all
  241. attributes.  Order of attributes is unimportant.  As usual, white space
  242. is irrelevant.  Boolean attributes may be preceded by "+" or "-" to turn
  243. them on or off; "+" is assumed if only the attribute name appears.
  244. Other attributes expect values.
  245.  
  246. A "*" prefix on any attribute, e.g. "*+edge" or "*linewidth 2",
  247. selects "override" status for that attribute.
  248.  
  249.      appearance {
  250.        +face               # draw faces of polygons
  251.        -edge               # don't draw edges of polygons
  252.        -transparent        # don't attempt transparency (not implemented)
  253.        +normal             # do draw surface-normal vectors
  254.        normscale .25       # ... with length .25 in object coordinates
  255.  
  256.        +evert              # do evert polygon normals where needed so as
  257.                            #   to always face the camera
  258.  
  259.        shading smooth      # or "shading constant" or "shading flat".
  260.                            # smooth = Gouraud shading; flat = faceted.
  261.  
  262.        linewidth 3         # lines & edges are 3 pixels wide.
  263.  
  264.        material {         # Here's a material definition;
  265.                            # it could also be read from a file as in
  266.                            #  "material < file.mat"
  267.  
  268.            ka  1.0         # ambient reflection coefficient.
  269.            ambient .3 .5 .3 # ambient color (red, green, blue components)
  270.                            # The ambient contribution to the shading is
  271.                            # the product of ka, the ambient color,
  272.                            # and the color of the ambient light.
  273.  
  274.            kd  0.8         # diffuse-reflection coefficient.
  275.            diffuse .9 1 .4 # diffuse color.
  276.                              # (In "shading constant" mode, the surface
  277.                              # is colored with the diffuse color.)
  278.  
  279.            ks 1.0          # specular reflection coefficient.
  280.            specular 1 1 1  # specular (highlight) color.
  281.            shininess  25   # specular exponent; larger values give
  282.                            # sharper highlights.
  283.  
  284.            alpha   1.0     # opacity; 0 = transparent (invisible)
  285.                            # when transparency is enabled.
  286.  
  287.            edgecolor   1 1 0  # line & edge color
  288.  
  289.            normalcolor 0 0 0  # color for surface-normal vectors
  290.        }
  291.  
  292.        lighting {         # Lighting model
  293.  
  294.            ambient  .3 .3 .3  # ambient light
  295.  
  296.            replacelights   # "Use only the following lights to
  297.                            # illuminate the objects under this
  298.                            # appearance."
  299.                            # Without "replacelights", any lights
  300.                            # are added to those already in the scene.
  301.  
  302.                            # Now a collection of real lights
  303.            light { 
  304.                color  1 .7 .6      # light color
  305.                position  1 0 .5 0  # light position [distant light]
  306.                                    # given in homogeneous coordinates.
  307.                                    # With fourth component = 0,
  308.                                    # this means a light coming from
  309.                                    # direction (1,0,.5).
  310.            }
  311.  
  312.            light {                        # Another light.
  313.                color 1 1 1
  314.                position  0 0 .5 1  # light at finite position ...
  315.                location camera     # specified in camera coordinates.
  316.                                    # (Since the camera looks toward -Z,
  317.                                    # this example places the light
  318.                                    # .5 unit behind the eye.)
  319.                # Possible "location" keywords:
  320.                #  global    light position is in world coordinates
  321.                #             This is the default if no location specified.
  322.                #  camera   position is in the camera's coordinate system
  323.                #  local    position is in the coordinate system where
  324.                #                   the appearance was defined
  325.            }
  326.        }                   # end lighting model
  327.      }                     # end appearance
  328.  
  329.  
  330. There are rules for inheritance of appearance attributes when several
  331. are imposed at different levels in the hierarchy.
  332.  
  333. For example, Geomview installs a backstop appearance which provides
  334. default values for most parameters; its control panels install other
  335. appearances which supply new values for a few attributes; user-supplied
  336. geometry may also contain appearances.
  337.  
  338. The general rule is that the child's appearance (the one closest to the
  339. geometric primitives) wins.  So setting an appearance attribute in an
  340. object's definition will prevent the viewer controls from affecting that
  341. object's display.
  342.  
  343.  
  344. Object File Formats
  345. ===================
  346.  
  347. `QUAD': collection of quadrilaterals
  348. ------------------------------------
  349.  
  350. The conventional suffix for a `QUAD' file is `.quad'.
  351.  
  352. The file syntax is
  353.  
  354.         [C][N][4]QUAD  -or-  [C][N][4]POLY           # Key word
  355.         VERTEX  VERTEX  VERTEX  VERTEX  # 4*N vertices for some N
  356.         VERTEX  VERTEX  VERTEX  VERTEX
  357.         ...
  358.  
  359. The leading key word is `[C][N][4]QUAD' or `[C][N][4]POLY',
  360. where the optional `C' and `N' prefixes indicate that each vertex
  361. includes colors and normals respectively.  That is, these files
  362. begin with one of the words
  363.  
  364. `QUAD' `CQUAD' `NQUAD' `CNQUAD' `POLY'
  365. `CPOLY' `NPOLY' `CNPOLY'
  366.  
  367. (but not `NCQUAD' or `NCPOLY').  `QUAD' and `POLY'
  368. are synonymous; both forms are allowed just for compatibility with
  369. ChapReyes.
  370.  
  371. Following the key word is an arbitrary number of groups of four
  372. vertices, each group describing a quadrilateral.  See the Vertex syntax
  373. above.  The object ends at end-of-file, or with a closebrace if
  374. incorporated into an object reference (see above).
  375.  
  376. A `QUAD BINARY' file format is accepted; *Note Binary format::.  The
  377. first word of binary data must be a 32-bit integer giving the number of
  378. quads in the object; following that is a series of 32-bit floats,
  379. arranged just as in the ASCII format.
  380.  
  381.  
  382. `MESH': rectangularly-connected mesh
  383. ------------------------------------
  384.  
  385. The conventional suffix for a `MESH' file is `.mesh'.
  386.  
  387. The file syntax is
  388.  
  389.      [C][N][Z][4][U][u][v]MESH    # Key word
  390.      NU NV            # Mesh dimensions
  391.                                   # NU*NV vertices, in format specified
  392.                                   # by initial key word
  393.      VERTEX(u=0,v=0)  VERTEX(1,0)  ... VERTEX(NU-1,0)
  394.      VERTEX(0,1) ...    VERTEX(NU-1,1)
  395.      ...
  396.      VERTEX(0,NV-1) ... VERTEX(NU-1,NV-1)
  397.  
  398. The key word is  `[C][N][Z][4][U][u][v]MESH'.
  399. The optional prefix characters mean:
  400.  
  401. `C'
  402.      Each vertex (see Vertices above) includes a 4-component color.
  403. `N'
  404.      Each vertex includes a surface normal vector.
  405. `Z'
  406.      Of the 3 vertex position values, only the Z component is present; X and
  407.      Y are omitted, and assumed to equal the mesh (u,v) coordinate so X
  408.      ranges from 0 .. (Nu-1), Y from 0 .. (Nv-1) where Nu and Nv are the mesh
  409.      dimensions -- see below.
  410. `4'
  411.      Vertices are 4D, each consists of 4 floating values.  `Z' and
  412.      `4' cannot both be present.
  413. `U'
  414.      Each vertex includes a 3-component texture space parameter.  This is
  415.      not yet implemented and should not be used.
  416. `u'
  417.      The mesh is wrapped in the u-direction, so the 
  418.      (0,v)'th vertex is connected to the (NU-1,v)'th for all v.
  419. `v'
  420.      The mesh is wrapped in the v-direction, so the (u,0)'th vertex is
  421.      connected to the (u,NV-1)'th for all u.  Thus a u-wrapped or
  422.      v-wrapped mesh is topologically a cylinder, while a uv-wrapped mesh is a
  423.      torus.
  424.  
  425. Note that the order of prefix characters is significant; a colored,
  426. u-wrapped mesh is a `CuMESH' not a `uCMESH'.
  427.  
  428. Following the mesh header are integers NU and NV,
  429. the dimensions of the mesh.
  430.  
  431. Then follow NU*NV vertices, each in the form given by the header.
  432. They appear in v-major order, i.e. if we name each vertex by (u,v)
  433. then the vertices appear in the order
  434.  
  435.      (0,0) (1,0) (2,0) (3,0) ...  (NU-1,0)
  436.      (0,1) (1,1) (2,1) (3,1) ...  (NU-1,1)
  437.      ...
  438.      (0,Nv-1)        ...  (NU-1,NV-1)
  439.  
  440. A `MESH BINARY' format is accepted; *Note Binary format::.  The
  441. values of NU and NV are 32-bit integers; all other values
  442. are 32-bit floats.
  443.  
  444.  
  445. Bezier Surfaces
  446. ---------------
  447.  
  448. The conventional file suffixes for Bezier surface files are `.bbp'
  449. or `.bez'.  A file with either suffix may contain either type of
  450. patch.
  451.  
  452. Syntax:
  453.  
  454.        [ST]BBP -or- [C]BEZ<NU><NV><ND>[_ST]
  455.                  # NU, NV are u- and v-direction 
  456.                  # polynomial degrees in range 1..6
  457.                  # ND = dimension: 3->3-D, 4->4-D (rational)
  458.                  # (The '<' and '>' do not appear in the input.)
  459.                  # NU,NV,ND are each a single decimal digit.
  460.                  # BBP form implies NU=NV=ND=3 so BBP = BEZ333.
  461.  
  462.              # Any number of patches follow the header
  463.                  # (NU+1)*(NV+1) patch control points
  464.                  # each 3 or 4 floats according to header
  465.        VERTEX(u=0,v=0)  VERTEX(1,0) ... VERTEX(NU,0)
  466.        VERTEX(0,1)               ... VERTEX(NU,1)
  467.        ...
  468.        VERTEX(0,NV)           ... VERTEX(NU,NV)
  469.  
  470.                  # ST texture coordinates if mentioned in header
  471.        `S'(u=0,v=0)    `T'(0,0)    `S'(0,NV) `T'(0,NV)
  472.        `S'(NU,0)    `T'(NU,0)    `S'(NU,NV) `T'(NU,NV)
  473.  
  474.                  # 4-component float (0..1) R G B A colors
  475.                  # for each patch corner if mentioned in header
  476.        `RGBA'(0,0)   `RGBA'(0,NV)
  477.        `RGBA'(NU,0)  `RGBA'(NU,NV)
  478.  
  479. These formats represent collections of Bezier surface patches, of
  480. degrees up to 6, and with 3-D or 4-D (rational) vertices.
  481.  
  482. The header keyword has the forms `[ST]BBP' or
  483. `[C]BEZ<NU><NV><ND>[_ST]' (the '<' and '>' are
  484. not part of the keyword.
  485.  
  486. The `ST' prefix on `BBP', or `_ST' suffix on
  487. `BEZuvn', indicates that each patch includes four pairs of
  488. floating-point texture-space coordinates, one for each corner of the
  489. patch.
  490.  
  491. The `C' prefix on `BEZuvn' indicates a colored patch,
  492. including four sets of four-component floating-point colors (red, green,
  493. blue, and alpha) in the range 0..1, one color for each corner.
  494.  
  495. NU and NV, each a single digit in the range 1..6, are the
  496. patch's polynomial degree in the u and v direction respectively. 
  497.  
  498. ND is the number of components in each patch vertex, and must be
  499. either `3' for 3-D or `4' for homogeneous coordinates, that
  500. is, rational patches.
  501.  
  502. `BBP' patches are bicubic patches with 3-D vertices, so `BBP'
  503. = `BEZ333' and `STBBP' = `BEZ333_ST'.
  504.  
  505. Any number of patches follow the header.  Each patch comprises a series
  506. of patch vertices, followed by optional (s,t) texture coordinates,
  507. followed by optional (r,g,b,a) colors.
  508.  
  509. Each patch has (NU+1)*(NV+1) vertices in v-major order, so that if we
  510. designate a vertex by its control point indices (u,v) the order is
  511.           (0,0) (1,0) (2,0) ...  (NU,0)
  512.           (0,1) (1,1) (2,1) ...  (NU,1)
  513.           ...
  514.           (0,NV)            ...  (NU,NV)
  515. with each vertex containing either 3 or 4 floating-point numbers
  516. as specified by the header.
  517.    
  518. If the header calls for ST coordinates, four pairs of floating-point
  519. numbers follow: the texture-space coordinates for the (0,0),
  520. (NU,0), (0,NV), and (NU,NV) corners of the
  521. patch, respectively.
  522.  
  523. If the header calls for colors, four four-component (red, green, blue,
  524. alpha) floating-point colors follow, one for each patch corner.
  525.  
  526. The series of patches ends at end-of-file, or with a closebrace if
  527. incorporated in an object reference.
  528.  
  529.  
  530. OFF Files
  531. ---------
  532.  
  533. The conventional suffix for `OFF' files is `.off'.
  534.  
  535. Syntax:
  536.  
  537.      [C][N][4]OFF        # Header keyword (optional)
  538.      NVERTICES  NFACES  NEDGES   # NEdges not used or checked
  539.  
  540.      X[0]  Y[0]  Z[0]    # Vertices, possibly with colors
  541.                      # and/or normals if `COFF' or `NOFF'
  542.      ...
  543.      X[NVERTICES-1]  Y[NVERTICES-1]  Z[NVERTICES-1]
  544.  
  545.                      # Faces
  546.                      # NV = # vertices on this face
  547.                      # V[0] ... V[NV-1]: vertex indices
  548.                      #        in range 0..NVERTICES-1
  549.      NV  V[0] V[1] ... V[NV-1]  COLORSPEC
  550.      ...
  551.                      # COLORSPEC continues past V[NV-1]
  552.                      # to end-of-line; may be 0 to 4 numbers
  553.                      # nothing: default
  554.                      #  integer: colormap index
  555.                      # 3 or 4 integers: RGB[A] values 0..255
  556.                      # 3 or 4 floats: RGB[A] values 0..1
  557.  
  558. `OFF' files (name for "object file format") represent collections
  559. of planar polygons with possibly shared vertices, a convenient way to
  560. describe polyhedra.  The polygons may be concave but there's no
  561. provision for polygons containing holes.
  562.  
  563. An `OFF' file may begin with the keyword `OFF'; it's
  564.  
  565.  
  566.  
  567. recommended but optional, as many existing files lack this keyword.
  568.  
  569. Three ASCII integers follow: NVERTICES, NFACES, and
  570. NEDGES.  Thse are the number of vertices, faces, and edges,
  571. respectively.  Current software does not use nor check NEDGES; it
  572. needn't be correct but must be present.
  573.  
  574. The vertex coordinates follow: dimension * NVERTICES
  575. floating-point values.  They're implicitly numbered 0 through
  576. NVERTICES-1.  dimension is either 3 (default) or 4 (specified by
  577. the key character `4' directly before `OFF' in the keyword).
  578.  
  579. Following these are the face descriptions, typically written
  580. with one line per face.  Each has the form
  581.      N  VERT1 VERT2 ... VERTN  [COLOR]
  582. Here N is the number of vertices on this face,
  583. and VERT1 through VERTN are indices into the list of
  584. vertices (in the range 0..NVERTICES-1).
  585.  
  586. The optional COLOR may take several forms.  Line breaks are
  587. significant here: the COLOR description begins after VERTN
  588. and ends with the end of the line (or the next # comment).  A
  589. COLOR may be:
  590.  
  591. nothing
  592.      the default color
  593. one integer
  594.      index into "the" colormap; see below
  595. three or four integers
  596.      RGB and possibly alpha values in the range 0..255
  597. three or four floating-point numbers
  598.      RGB and possibly alpha values in the range 0..1
  599.  
  600. For the one-integer case, the colormap is currently read from the file
  601. `cmap.fmap' in Geomview's `data' directory.  Some better
  602. mechanism for supplying a colormap is likely someday.
  603.  
  604. The meaning of "default color" varies.  If no face of the object has a
  605. color, all inherit the environment's default material color.  If some
  606. but not all faces have colors, the default is gray (R,G,B,A=.666).
  607.  
  608. A `[C][N]OFF BINARY' format is accepted; *Note Binary format::.  It
  609. resembles the ASCII format in almost the way you'd expect, with 32-bit
  610. integers for all counters and vertex indices and 32-bit floats for
  611. vertex positions (and vertex colors or normals if
  612. `COFF'/`NOFF'/`CNOFF' format).
  613.  
  614. Exception: each face's vertex indices are followed by an integer
  615. indicating how many color components accompany it.  Face color
  616. components must be floats, not integer values.  Thus a colorless
  617. triangular face might be represented as
  618.  
  619.      int int int int int
  620.      3   17   5   9   0
  621.  
  622. while the same face colored red might be
  623.  
  624.      int int int int int float float float float
  625.       3  17   5   9   4   1.0   0.0   0.0   1.0
  626.  
  627.  
  628.  
  629. VECT Files
  630. ----------
  631.  
  632. The conventional suffix for `VECT' files is `{.vect}.'
  633. Syntax:
  634.  
  635.      [4]VECT
  636.      NPOLYLINES  NVERTICES  NCOLORS
  637.  
  638.      NV[0] ... NV[NPOLYLINES-1]     # number of vertices
  639.                                                 # in each polyline
  640.  
  641.      NC[0] ... NC[NPOLYLINES-1]     # number of colors supplied
  642.                                                 # in each polyline
  643.  
  644.      VERT[0] ... VERT[NVERTICES-1]  # All the vertices
  645.                                                 # (3*NVertices floats)
  646.  
  647.      COLOR[0] ... COLOR[NCOLORS-1]  # All the colors
  648.                                                 # (4*NColors floats, RGBA)
  649.  
  650. `VECT' objects represent lists of polylines (strings of connected
  651. line segments, possibly closed).  A degenerate polyline can be used to
  652. represent a point.
  653.  
  654. A `VECT' file begins with the key word `VECT' or `4VECT'
  655. and three integers: NLINES, NVERTICES, and NCOLORS.
  656. Here NLINES is the number of polylines in the file,
  657. NVERTICES the total number of vertices, and NCOLORS the
  658. number of colors as explained below.
  659.  
  660. Next come NLINES integers
  661.  
  662.      NV[0] NV[1] NV[2] ... NV[NLINES-1]
  663.  
  664. giving the number of vertices in each polyline.  A negative number
  665. indicates a closed polyline; 1 denotes a single-pixel point.  The sum
  666. (of absolute values) of the NV[I] must equal NVERTICES.
  667.  
  668. Next come NLINES more integers Nc[i]: the number of colors in
  669. each polyline.  Normally one of three values:
  670.  
  671. 0
  672.      No color is specified for this polyline.  It's drawn in the same color
  673.      as the previous polyline.
  674. 1
  675.      A single color is specified.  The entire polyline is drawn in that
  676.      color.
  677. abs(NV[I])
  678.      Each vertex has a color.  Either each segment is drawn in the
  679.      corresponding color, or the colors are smoothly interpolated along the
  680.      line segments, depending on the implementation.
  681.  
  682. The sum of the NC[I] must equal NCOLORS.
  683.  
  684. Next come NVERTICES groups of 3 or 4 floating-point numbers: the
  685. coordinates of all the vertices.  If the keyword is 4VECT then
  686. there are 4 values per vertex.  The first abs(NV[0]) of them form
  687. the first polyline, the next abs(NV[1]) form the second and so on.
  688.  
  689. Finally NCOLORS groups of 4 floating-point numbers give red,
  690. green, blue and alpha (opacity) values.  The first NC[0] of them
  691. apply to the first polyline, and so on.
  692.  
  693. A VECT BINARY format is accepted; *Note Binary format::.  The
  694. binary format exactly follows the ASCII format, with 32-bit ints where
  695. integers appear, and 32-bit floats where real values appear.
  696.  
  697.  
  698.  
  699.  
  700. INST Files
  701. ----------
  702.  
  703. The conventional suffix for a `INST' file is `.inst'.
  704.  
  705. An `INST' applies a 4x4 transformation to another OOGL object.  It
  706. begins with `INST' followed by these sections which may appear in
  707. any order:
  708.      geom OOGL-OBJECT
  709. specifies the OOGL object to be instantiated.  *Note References::, for
  710. the syntax of an OOGL-OBJECT.  The keyword `unit' is a
  711. synonym for `geom'.
  712.      transform   ["{"] `4x4 transform' ["}"]
  713. specifies a single transformation matrix.  Either the
  714. matrix may appear literally as 16 numbers, or there may be
  715. a reference to a "transform" object, i.e.
  716.      "<" file-containing-4x4-matrix
  717. or
  718.      ":" symbol-representing-"transform"-object>
  719.  
  720. Another way to specify the transformation is
  721.  
  722.      transforms
  723.          OOGL-OBJECT
  724.  
  725. The OOGL-OBJECT must be a `TLIST' object (list of
  726. transformations) object, or a `LIST' whose members are ultimately
  727. `TLIST' objects.  In effect, the `transforms' keyword takes a
  728. collection of 4x4 matrices and replicates the `geom' object, making
  729. one copy for each 4x4 matrix.
  730.  
  731. If no `transform' nor `transforms' keyword appears, no
  732. transformation is applied (actually the identity is applied).  This
  733. might be useful, e.g., for wrapping an appearance around an
  734. externally-supplied object.
  735.  
  736. *Note Transformation matrices::, for the matrix format.
  737.  
  738. There is no INST BINARY format.
  739.  
  740. INST Examples
  741. .............
  742.  
  743. Here are some examples of `INST' files
  744.  
  745.      INST
  746.           unit < xyz.vect
  747.           transform {
  748.              1 0 0 0
  749.              0 1 0 0
  750.              0 0 1 0
  751.              1 3 0 1
  752.           }
  753.  
  754.      { appearance { +edge  material { edgecolor 1 1 0 } }
  755.          INST geom < mysurface.quad }
  756.  
  757.      {INST transform {: T} geom {<dodec.off}}
  758.  
  759.      { INST
  760.           transforms
  761.               { LIST
  762.               { < some-matrices.prj }
  763.               { < others.prj }
  764.               { TLIST <still more of them> }
  765.          
  766.               }
  767.           geom
  768.               { # stuff replicated by all the above matrices
  769.               ...
  770.               }
  771.      }
  772.  
  773.  
  774. LIST Files
  775. ----------
  776.  
  777. The conventional suffix for a `LIST' file is `.list'.
  778.  
  779. A list of OOGL objects
  780.  
  781. Syntax:
  782.  
  783.      LIST
  784.          OOGL-OBJECT
  785.          OOGL-OBJECT
  786.          ...
  787.  
  788. Note that there's no explicit separation between the oogl-objects, so
  789. they should be enclosed in curly braces ({ }) for sanity.  Likewise
  790. there's no explicit marker for the end of the list; unless appearing
  791. alone in a disk file, the whole construct should also be wrapped in
  792. braces, as in:
  793.  
  794.         { LIST { QUAD ... } { < xyz.quad } }
  795.  
  796. A `LIST' with no elements, i.e. `{ LIST }', is valid, and is
  797. the easiest way to create an empty object.  For example, to remove a
  798. symbol's definition you might write
  799.  
  800.         { define somesymbol  { LIST } }
  801.  
  802.  
  803.  
  804. TLIST Files
  805. -----------
  806.  
  807.  
  808. The conventional suffix for a `TLIST' file is `.grp' ("group")
  809. or or `.prj' ("projective" matrices).
  810.  
  811. Collection of 4x4 matrices, used in the `transforms' section of and
  812. `INST' object.
  813.  
  814. Syntax:
  815.  
  816.      TLIST            # key word
  817.  
  818.      <4x4 matrix (16 floats)>
  819.      ...                # Any number of 4x4 matrices
  820.  
  821. `TLIST's are used only within the `transforms' clause of an
  822. `INST' object.  They cause the `INST's `geom' object to
  823. be instantiated once under each of the transforms in the `TLIST'.
  824. The effect is like that of a `LIST' of `INST's each with a
  825. single transform, and all referring to the same object, but is more
  826. efficient.
  827.  
  828. Be aware that a `TLIST' is a kind of geometry object, distinct from a 
  829. `transform' object.  Some contexts expect one type of object,
  830. some the other.  For example in
  831.      INST transform { : MYT } geom { ... }
  832. MYT must be a transform object, which might have been
  833. created with the gcl
  834.      (read transform { define myT 1 0 0 1 ... })
  835. while in
  836.          INST transforms { : MYTS } geom { ... }
  837.      or  INST transforms { LIST {: MYTS} {< more.prj} } geom { ... }
  838. MYTS must be a geometry object, defined e.g. with
  839.          (read geometry { define MYTS { TLIST 1 0 0 1 ... } })
  840.  
  841. A `TLIST BINARY' format is accepted.  Binary data begins with a
  842. 32-bit integer giving the number of transformations, followed by that
  843. number of 4x4 matrices in 32-bit floating-point format.  The order of
  844. matrix elements is the same as in the ASCII format.
  845.  
  846.  
  847.  
  848. GROUP Files
  849. -----------
  850.  
  851. This format is obsolete, but is still accepted.  It combined the
  852. functions of `INST' and `TLIST', taking a series of
  853. transformations and a single Geom (`unit') object, and replicating
  854. the object under each transformation.
  855.  
  856.      GROUP ... < matrices > ... unit { OOGL-OBJECT }
  857.  
  858. is still accepted and effectively translated into
  859.  
  860.      INST
  861.          transforms { TLIST ... <matrices> ... }
  862.          unit { OOGL-OBJECT }
  863.  
  864.  
  865. DISCGRP Files
  866. -------------
  867.  
  868. This format is for discrete groups, such as appear in the theory of
  869. manifolds or in symmetry patterns.  This format has its own man page.
  870. See discgrp(5).
  871.  
  872.  
  873. Non-geometric objects
  874. =====================
  875.  
  876.  
  877. The syntax of these objects is given in the form used in
  878. *Note References::, where "quoted" items should appear literally but
  879. without quotes, square bracketed ([ ]) items are optional, and | separates
  880. alternative choices.
  881.  
  882. Transform Objects
  883. -----------------
  884.  
  885. Where a single 4x4 matrix is expected -- as in the
  886. `INST' `transform' field, the camera's `camtoworld' transform
  887. and the Geomview `xform*' commands -- use a transform object.
  888.  
  889. Note that a transform is distinct from a `TLIST', which is a type
  890. of geometry.  `TLIST's can contain one or more 4x4 transformations;
  891. "transform" objects must have exactly one.
  892.  
  893. Why have both?  In many places -- e.g. camera positioning -- it's only
  894. meaningful to have a single transform.  Using a separate object type
  895. enforces this.
  896.  
  897. Syntax for a transform object is
  898.  
  899.      <transform> ::= 
  900.        [ "{" ]             (curly brace, generally needed to make
  901.                             the end of the object unambiguous.)
  902.  
  903.         [ "transform" ]    (optional keyword; unnecessary if the type
  904.                             is determined by the context, which it
  905.                             usually is.)
  906.         [ "define" <name> ]
  907.                            (defines a transform named <name>, setting
  908.                             its value from the stuff which follows)
  909.  
  910.            <sixteen floating-point numbers>
  911.                            (interpreted as a 4x4 homogeneous transform
  912.                     given row by row, intended to apply to a
  913.                             row vector multiplied on its LEFT, so that e.g.
  914.                             Euclidean translations appear in the bottom row)
  915.         | 
  916.            "<" <filename>  (meaning: read transform from that file)
  917.         |
  918.            ":" <name>      (meaning: use variable <name>,
  919.                              defined elsewhere; if undefined the initial
  920.                              value is the identity transform)
  921.  
  922.       [ "}" ]              (matching curly brace)
  923.  
  924. The whole should be enclosed in { braces }.  Braces are not essential
  925. if exactly one of the above items is present, so e.g. a 4x4 array of
  926. floats standing alone may but needn't have braces.
  927.  
  928. Some examples, in contexts where they might be used:
  929.  
  930.      # Example 1: A gcl command to define a transform
  931.      # called "fred"
  932.  
  933.      (read transform { transform  define fred
  934.               1 0 0 0
  935.               0 1 0 0
  936.               0 0 1 0
  937.              -3 0 1 1
  938.          }
  939.      )
  940.  
  941.      # Example 2:  A camera object using transform
  942.      # "fred" for camera positioning
  943.      # Given the definition above, this puts the camera at
  944.      # (-3, 0, 1), looking toward -Z.
  945.  
  946.      { camera
  947.              halfyfield 1
  948.              aspect 1.33
  949.              camtoworld { : fred }
  950.      }
  951.  
  952.  
  953. cameras
  954. -------
  955.  
  956. A camera object specifies the following properties of a camera:
  957.  
  958. position and orientation
  959.      specified by either a camera-to-world or world-to-camera transformation;
  960.      this transformation does not include the projection, so it's typically
  961.      just a combination of translation and rotation.  Specified as a
  962.      transform object, typically a 4x4 matrix.
  963. "focus" distance
  964.      Intended to suggest a typical distance from the camera to the object of
  965.      interest; used for default camera positioning (the camera is placed at
  966.      (X,Y,Z) = (0,0,focus) when reset) and for adjusting field-of-view when
  967.      switching between perspective and orthographic views.
  968. window aspect ratio
  969.      True aspect ratio in the sense <Xsize>/<Ysize>.  This normally should
  970.      agree with the aspect ratio of the camera's window.  Geomview normally
  971.      adjusts the aspect ratio of its cameras to match their associated
  972.      windows.
  973. near and far clipping plane distances
  974.      Note that both must be strictly greater than zero.  Very large
  975.      <far>/<near> distance ratios cause Z-buffering to behave badly; part of
  976.      an object may be visible even if somewhat more distant than another.
  977. field of view
  978.      Specified in either of two forms.
  979.             `fov '
  980.      
  981.           is the field of view -- in degrees if perspective, or linear
  982.           distance if orthographic -- in the *shorter* direction.
  983.             `halfyfield '
  984.      
  985.           is half the projected Y-axis field, in world coordinates (not angle!),
  986.           at unit distance from the camera.  For a perspective camera, halfyfield
  987.           is related to angular field:
  988.  
  989.                    halfyfield = tan( Y_axis_angular_field / 2 )
  990.  
  991.           while for an orthographic one it's simply:
  992.  
  993.                        halfyfield = Y_axis_linear_field / 2
  994.  
  995.  
  996.      This odd-seeming definition is (a) easy to calculate with and
  997.      (b) well-defined in both orthographic and perspective views.
  998.  
  999.  
  1000. The syntax for a camera is:
  1001.  
  1002.      <camera> ::=
  1003.  
  1004.         [ "camera" ]            (optional keyword)
  1005.          [ "{" ]            (opening brace, generally required)
  1006.          [ "define" <name> ]
  1007.  
  1008.          "<" <filename>
  1009.            |
  1010.          ":" <name>
  1011.            |
  1012.                      (or any number of the following,
  1013.                       in any order...)
  1014.  
  1015.          "perspective"  {"0" | "1"}        (default 1)
  1016.                          (otherwise orthographic)
  1017.  
  1018.          "stereo"       {"0" | "1"}        (default 0)
  1019.                          (otherwise mono)
  1020.  
  1021.          "worldtocam" <transform>    (see transform syntax above)
  1022.  
  1023.          "camtoworld" <transform>
  1024.                      (no point in specifying both
  1025.                       camtoworld and worldtocam; one is
  1026.                       constrained to be the inverse of                         the other)
  1027.  
  1028.          "halfyfield" <half-linear-Y-field-at-unit-distance>
  1029.                      (default tan 40/2 degrees)
  1030.  
  1031.          "fov"        (angular field-of-view if perspective,
  1032.                   linear field-of-view otherwise.
  1033.                   Measured in whichever direction is smaller,
  1034.                   given the aspect ratio.  When aspect ratio
  1035.                   changes -- e.g. when a window is reshaped --
  1036.                   "fov" is preserved.)
  1037.  
  1038.          "frameaspect" <aspect-ratio>    (X/Y) (default 1.333)
  1039.  
  1040.          "near"  <near-clipping-distance>    (default 0.1)
  1041.     
  1042.          "far"    <far-clipping-distance>        (default 10.0)
  1043.  
  1044.          "focus" <focus-distance>        (default 3.0)
  1045.  
  1046.     
  1047.           [ "}" ]                (matching closebrace)
  1048.  
  1049.  
  1050. Info file: geomview,    -*-Text-*-
  1051. produced by texinfo-format-buffer
  1052. from file: geomview.tex
  1053.  
  1054.  
  1055.  
  1056. window
  1057. ------
  1058.  
  1059. A window object specifies size, position, and other window-system
  1060. related information about a window in a device-independent way.
  1061.  
  1062. The syntax for a window object is:
  1063.  
  1064.      window ::=
  1065.  
  1066.          [ "window" ]            (optional keyword)
  1067.            [ "{" ]            (curly brace, often required)
  1068.  
  1069.                          (any of the following, in any order)
  1070.  
  1071.              "size"  <xsize> <ysize>
  1072.                      (size of the window)
  1073.  
  1074.              "position"  <xmin> <xmax> <ymin> <ymax>
  1075.                      (position & size)
  1076.  
  1077.  
  1078.              "noborder"
  1079.                      (specifies the window should
  1080.                       have no window border)
  1081.  
  1082.              "pixelaspect"  <aspect>
  1083.                      (specifies the true visual aspect ratio
  1084.                       of a pixel in this window in the sense
  1085.                       xsize/ysize, normally 1.0.
  1086.                       For stereo hardware which stretches the
  1087.                       display vertically by a factor of 2,
  1088.                       "pixelaspect 0.5" might do.
  1089.                       The value is used when computing the
  1090.                       projection of a camera associated with
  1091.                       this window.)
  1092.  
  1093.            [ "}" ]            (matching closebrace)
  1094.  
  1095. Window objects are used in the Geomview `window' and
  1096. `ui-panel' commands to set default properties for future windows or
  1097. to change those of an existing window.
  1098.  
  1099.  
  1100.